/**************************************************************************************** 
 Copyright © 2003-2012 ZTEsoft Corporation. All rights reserved. Reproduction or       <br>
 transmission in whole or in part, in any form or by any means, electronic, mechanical <br>
 or otherwise, is prohibited without the prior written consent of the copyright owner. <br>
 ****************************************************************************************/
package com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.attr;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.client.vo.scene.CommonAttrVO;
import com.iwhalecloud.bss.kite.common.util.KiteListUtils;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.manager.api.IOperateSceneInstService;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.web.service.accept.attr.handler.AbstractAttrHandler;

/** 
 * <Description> <br> 
 *  
 * @author tengg<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2022年4月12日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.web.service.accept.handler.attr <br>
 */
@Service
public class GroupNewCustNameAttrHander extends AbstractAttrHandler {

    @Resource
    private IQuerySceneInstService querySceneInstService;
    
    @Resource
    private IOperateSceneInstService operateSceneInstService;
    /**
     * Description: <br> 
     *  
     * @author tengg<br>
     * @taskId <br>
     * @param commonAttr <br>
     */ 
    @Override
    public void init(CommonAttrVO commonAttr) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public DataResult<Boolean> apply(String sceneInstId, String fieldName, String value, String valueDesc) {
        List<KiteAttr> kiteAttrList = querySceneInstService.listCommonAttrsByModuleId(sceneInstId, "2021113001");
        if (KiteListUtils.isNotEmpty(kiteAttrList)) {
            kiteAttrList.stream().forEach(kiteAttr ->{
                if (KiteStringUtils.isNotEmpty(kiteAttr.getValue())) {
                    kiteAttr.setValue("");
                    kiteAttr.setValueDesc("");
                    operateSceneInstService.setCommonAttr(sceneInstId, kiteAttr);
                }
            });
        }
        return super.apply(sceneInstId, fieldName, value, valueDesc);
    }
}
